package HashTable_08;

/*
 * @Author 罗
 * @date 2020/3/19 - 8:12 下午
 *
 */

import HashTable_08.DataStructure.EmpLinkedList;
import HashTable_08.DataStructure.HashTableEmp;
import HashTable_08.entity.Employee;
import org.junit.Test;

import java.util.Scanner;

public class test {

    @Test
    public void test() {
        HashTableEmp hashTableEmp = new HashTableEmp(10);
        hashTableEmp.add(new Employee(7, "罗"));
        hashTableEmp.add(new Employee(3, "呜啊了"));
        hashTableEmp.add(new Employee(51, "王"));

        String cmd;
        int employeeId;
        boolean run = true;
        Scanner scanner = new Scanner(System.in);
        while (run) {
            System.out.println("add:添加数据");
            System.out.println("list:列出数据");
            System.out.println("exit:退出系统");
            System.out.println("delete:通过id删除雇员");
            System.out.println("find:根据id查找雇员");
            cmd = scanner.next();
            switch (cmd) {
                case "add": {
                    System.out.println("请输入要添加的员工id");
                    employeeId = scanner.nextInt();
                    Employee employee = new Employee(employeeId);
                    hashTableEmp.add(employee);
                }
                break;
                case "list": {
                    hashTableEmp.list();
                }
                break;
                case "delete": {
                    System.out.println("请输入要删除员工的id");

                    hashTableEmp.deleteById(scanner.nextInt());
                }
                break;
                case "find": {
                    System.out.println("请输入要查找员工的id");
                    int id = scanner.nextInt();
                    hashTableEmp.findEmployeeById(id);
                }
                break;
                case "exit": {
                    run = false;
                    scanner.close();
                }
                break;
            }
        }

    }
}
